﻿@inject Blazored.LocalStorage.ILocalStorageService localStorage
@inject HttpClient Http
<h3>HttpInterceptor</h3>

@code {
    // further usage for jwt token
        // Head
    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            var token = await localStorage.GetItemAsync<string>("jwtToken");
            if (!string.IsNullOrEmpty(token))
            {
                Http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
            }
        }
    }
}
